import threading
import time
from typing import Callable


class KeepTimer:

    def __init__(self):
        self.terminated = False
        self.threat = None

    def start_back(self, func: Callable, mis: float=5):
        self.terminated = False
        self.threat = threading.Thread(target=self.__main,
                                       kwargs={'func': func,
                                               'mis': mis})
        self.threat.start()

    def stop_back(self):
        self.terminated = True
        self.threat.join(10)

    def __main(self, func, mis):
        while not self.terminated:
            print('KeepTimer call once!')
            time.sleep(mis)
            func()
